package com.edu.exam.entity.personnel.student;

import com.edu.exam.enums.student.EnrollmentStatus;
import com.edu.exam.enums.student.GraduationStatus;
import jakarta.persistence.*;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 学籍信息实体类
 * [所属模块] F-04 学籍管理模块
 * 对应数据库表：student_enrollment
 */
@Entity
@Table(name = "student_enrollment")
public class StudentEnrollment {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotBlank(message = "学籍号不能为空")
    @Size(max = 50, message = "学籍号长度不能超过50个字符")
    @Column(name = "enrollment_number", unique = true, nullable = false, length = 50)
    private String enrollmentNumber;

    @NotNull(message = "学生ID不能为空")
    @Column(name = "student_id", nullable = false)
    private Long studentId;

    @NotNull(message = "行政班级ID不能为空")
    @Column(name = "class_id", nullable = false)
    private Long classId;

    @NotNull(message = "学籍状态不能为空")
    @Enumerated(EnumType.STRING)
    @Column(name = "current_status", nullable = false, length = 20)
    private EnrollmentStatus currentStatus = EnrollmentStatus.ENROLLED;

    @NotNull(message = "入学时间不能为空")
    @Column(name = "enrollment_date", nullable = false)
    private LocalDate enrollmentDate;

    @Column(name = "expected_graduation_date")
    private LocalDate expectedGraduationDate;

    @Column(name = "actual_graduation_date")
    private LocalDate actualGraduationDate;

    @Enumerated(EnumType.STRING)
    @Column(name = "graduation_status", length = 30)
    private GraduationStatus graduationStatus;

    @Column(name = "graduation_set_time")
    private LocalDateTime graduationSetTime;

    @Size(max = 50, message = "毕业状态设置人长度不能超过50个字符")
    @Column(name = "graduation_set_by", length = 50)
    private String graduationSetBy;

    @Size(max = 200, message = "毕业原因长度不能超过200个字符")
    @Column(name = "graduation_reason", length = 200)
    private String graduationReason;

    @Size(max = 1000, message = "备注信息长度不能超过1000个字符")
    @Column(name = "remarks", length = 1000)
    private String remarks;

    @DecimalMin(value = "0.00", message = "入学成绩不能小于0")
    @DecimalMax(value = "999.99", message = "入学成绩不能大于999.99")
    @Column(name = "admission_score", precision = 5, scale = 2)
    private BigDecimal admissionScore;

    @Size(max = 200, message = "毕业中学长度不能超过200个字符")
    @Column(name = "origin_school", length = 200)
    private String originSchool;

    @Column(name = "deleted", nullable = false)
    private Boolean deleted = false;

    @Column(name = "version", nullable = false)
    private Integer version = 0;

    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    @Size(max = 50, message = "创建人长度不能超过50个字符")
    @Column(name = "created_by", length = 50)
    private String createdBy;

    @Size(max = 50, message = "更新人长度不能超过50个字符")
    @Column(name = "updated_by", length = 50)
    private String updatedBy;

}